package com.codebattery.controller;


import com.codebattery.domain.model.DeviceInfo;
import com.codebattery.domain.model.NodeInfo;
import com.codebattery.service.DeviceService;
import com.codebattery.service.DictService;
import com.codebattery.service.NodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api("设备接口")
@RestController
@RequestMapping(value="device")
public class DeviceController {

    private static final Logger logger = LoggerFactory.getLogger(DeviceController.class);

    @Autowired
    private DeviceService deviceService;
    @Autowired
    private DictService dictService;

    @ApiOperation(value="获取设备列表",notes="获取设备列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query",  name = "page", value = "当前页", required = true),
            @ApiImplicitParam(paramType = "query",  name = "pageSize", value = "分页大小", required = true)})
    @RequestMapping(value="",method = RequestMethod.POST)
    @ResponseBody
    public Page<DeviceInfo> list(@PageableDefault(page = 0, size = 20) Pageable pageable) {
        logger.debug("获取设备列表");

        dictService.findAllDicts();

        return deviceService.list(pageable);
    }

}
